package com.duowei.diandan.constant;

import android.content.SharedPreferences;
import android.preference.PreferenceManager;

import com.duowei.diandan.R;
import com.duowei.diandan.app.App;

public class NetConfig {

    /**
     * 获取保存的服务器IP
     */
    public static String getServerUrl() {
        return "http://" + getServerIp() + "/server/ServerSvlt";
    }

    public static String getServerFoodImagesUrl() {
        return "http://" + getServerIp() + "/server/food_images/";
    }

    public static String getServerWelcomeImagesUrl() {
        return "http://" + getServerIp() + "/server/welcome_images/";
    }

    public static String getRollMessageUrl() {
        return "http://" + getServerIp() + "/server/message.txt";
    }

    public static String getWeixinQrcodeUrl() {
        return "http://" + getServerIp() + "/server/logo.png";
    }

    public static String getServerIp() {
        SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(App.getApp());
        String ip = sharedPref.getString(App.getApp().getString(R.string.pref_key_server_ip), "");
        if (ip.contains(":")) {
            return ip;
        } else {
            return ip + ":2233";
        }
    }

    public static String getWeiXinServerUrl(String ip) {
        return "http://" + ip + ":2233/serverandroid/ServerSvlt";
    }
}
